package com.leo.customer.service.impl

import com.leo.customer.entity.dao.OrganizeDao
import com.leo.customer.entity.pojo.Organize
import com.leo.customer.service.OrganizeService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.domain.Page
import org.springframework.data.domain.PageRequest
import org.springframework.data.domain.Sort
import org.springframework.stereotype.Service

@Service
class OrganizeServiceImpl : OrganizeService{

    @Autowired
    lateinit var organizeDao: OrganizeDao

    override fun createOrEditOrganize(organize: Organize) : Organize? {
        return organizeDao.save(organize)
    }

    //默认按照创建时间倒序排列
    override fun organizeList(pageNum:Int, size:Int, sort: Sort): Page<Organize> {
       return organizeDao.findAll(PageRequest.of(pageNum, size, sort))
    }

    override fun getOrganize(id: Int): Organize? {
        return organizeDao.getOne(id)
    }

}
